package com.operate.api.app.opinion.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.operate.api.base.Constants;
import com.operate.api.operate.opinion.domain.vo.OpinionAddVO;
import com.operate.api.base.ApiIndex;
import com.operate.api.base.R;
import com.operate.api.operate.opinion.service.IOpinionService;
import com.operate.util.BindingResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api( tags = ApiIndex.AppOpinionController)
@SaCheckLogin
@RequestMapping(value = "/api/app/opinion")
@RestController
public class AppOpinionController {


    @Autowired
    private IOpinionService service;

    @ApiOperation(value = "添加意见反馈[需要登录]")
    @PostMapping(value = "/add")
    public R create(@ApiParam(value = "添加参数") @Valid @RequestBody OpinionAddVO vo, BindingResult bindingResult) {
        R result= BindingResultUtil.BindingResult(bindingResult);
        if(result.getCode()== Constants.SYS_SUCCESS){
            service.add(vo);
        }
        return result;
    }



}
